import {Component, EventEmitter, OnInit} from '@angular/core';

/**
 * shared.CameraComponent demo
 */
@Component({
    selector: 'kylin-camera-demo',
    templateUrl: './camera-demo.component.html',
    styleUrls: [
        './camera-demo.component.less'
    ]
})
export class CameraDemoComponent implements OnInit {
    cameraGroupList: any = [];
    selectedGroups: Array<any> = [];
    startDate: any;
    endDate: any;
    selectedGroupsStr: string;
    loading = false;

    ngOnInit() {
        // 获取摄像头分组列表
        this.cameraGroupList = this.getCameraGroupList();
    }

    getCameraGroupList() {
        // 获取方式从 service中方法代替
        return [
            {
                ip: '39.155.157.198',
                port: 3002,
                username: 'admin',
                password: 'auto1234',
                checked: false

            },
            {
                ip: '1.85.57.242',
                port: 8800,
                username: 'admin',
                password: '12345',
                checked: false
            }
        ];
        /*{
            ip: '222.70.128.17',
            port: 8001,
            username: 'admin',
            password: '12345',
            labelName: '南京养老院摄像头组'
        }*/
    }

    refreshStatus() {
        const selectedGroups: Array<any> = [];  // 下拉框中显示，当前选中摄像头组的信息
        let selectedGroupsStr = '';
        this.cameraGroupList.map((item, index) => {
            if (item.checked) {
                selectedGroups.push(item);
                selectedGroupsStr += item.ip + '\t\t';
            }
        });
        this.selectedGroups = selectedGroups;
        this.selectedGroupsStr = selectedGroupsStr;
    }

    changeLoading($event) {
        console.log('===============');
        // debugger
        this.loading = $event;
    }
}
